package cn.edu.hnit.javaee.experiments.experiment02.dao;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

import cn.edu.hnit.javaee.experiments.experiment02.model.GameActivity;


public class GameActivityRepository {
	
	private List<GameActivity> gameActivities = new ArrayList();
	
	// 将截至日期晚于date的活动返回
	public List<GameActivity> findActiveActivities(LocalDateTime date) {
		List<GameActivity> currentActivities = new ArrayList();
		
		for(GameActivity gameActivity: gameActivities) {
			if(gameActivity.getEndTime().isAfter(date) && 
					gameActivity.getStartTime().isBefore(date)) {
				currentActivities.add(gameActivity);
			}
		}
		return currentActivities;
	}
	
	public void addActivity(GameActivity gameActivity) {
		gameActivities.add(gameActivity);
	}
	
}
